package com.Jshop.search.pojo;

import java.util.Map;

/**
 * 用来接收前端传过来的搜索JSON对象
 * */
public class SearchRequest {

    //搜索条件  搜索框
    private String key;
    //当前页
    private Integer page;

    //规格参数相关  参数 + 参数值
    private Map<String,String> filters;

    //每页 4 * 5 不可更改 固定大小
    private static final Integer DEFAULT_SIZE = 20;
    // 默认第一页开始 默认页
    private static final Integer   DEFAULT_PAGE = 1;


    public Map<String, String> getFilters() {
        return filters;
    }


    public void setFilters(Map<String, String> filters) {
        this.filters = filters;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Integer getPage() {
        //若无指定第几页，默认第一页
        if (page == null){
            return DEFAULT_PAGE;
        }
        //页码不能小于1
        return Math.max(DEFAULT_PAGE, page);
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public static Integer getSize() {
        return DEFAULT_SIZE;
    }
}
